home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / asm_n_z.zip / STROBE.ASM < prev    next >
Assembly Source File  |  1989-01-13  |  21KB  |  532 lines

  1.         page    ,132                    ; print in condensed mode
  2.  
  3.         title   STROBE - Monitor a memory field for changes  -  P. Quale 3/87
  4. cseg    segment para
  5.         assume  cs:cseg,ds:cseg,es:nothing,ss:nothing
  6.  
  7.                 org     2ch
  8. env_seg         dw      ?               ;pointer to our copy of environment
  9.                 org     80h             ;parm list starts here...
  10. parm_len        db      ?               ;its length
  11. parm_char       db      127 dup(?)      ;the parms
  12.         org     100h
  13. strobe  proc    near
  14. begin:
  15.         jmp     init                    ;go to once-only code
  16.  
  17. prog_id:db      'STROBE 1.02 '
  18.         db      'IBM Internal Use Only '
  19.         db      'P. Quale 03/87'
  20. id_end  equ     $
  21.  
  22. ;history:
  23. ;    1.01, 05/26/87: revised to incorporate changes suggested by Kevin McCarthy.
  24. ;       The addresses being monitored can now be patched on the fly by patching
  25. ;       new values into the fields intvect and intvect2, which have been
  26. ;       changed from EQU values to doubleword pointers.
  27.  
  28. ;    1.02, 01/13/89: STROBE now releases its memory when 'R'emoved.  Also
  29. ;       removed a potential BRS bug if a derivative program were to have an
  30. ;       ASSUME DS:CSEG directive in the timer interrupt routine, by changing
  31. ;       the exit statement from 'JMP OLDVECT' to 'JMP CS:OLDVECT'.
  32.  
  33. ;-------macro to simplify window repositioning
  34. posw    macro   name,row,column                 ;convert row/column location
  35. name    equ     ((row-1)*160)+((column-1)*2)    ;to position in video buffer
  36.         endm
  37.  
  38. ;-------macro to define field positions within the window
  39. posf    macro   name,row,column                 ;convert line/column location
  40. name    equ     corner1+((row-1)*160)+((column-1)*2)    ;to pos in video buffer
  41.         endm
  42.  
  43.         db      0               ;waste a byte to align patch area nicely
  44. old_vect        label   dword           ;original timer vector saved here
  45. old_ofs         dw      0               ;offset
  46. old_seg         dw      0               ;segment
  47. ;               keep old_vect as close to front of program as possible
  48.  
  49.         page
  50. ;-------entries on this page are grouped together to facilitate
  51. ;-------changes in window location or storage area(s) being tracked
  52.  
  53. ;-------next entries define the control block to be "watched"
  54. ;-------in this case, we watch to see when int 21 gets hooked
  55. intnum          equ     021h            ;interrupt number we care about
  56. intvect         dw      intnum*4,0      ;offset, segment (patchable)
  57. prev_value      dw      2 dup(?)        ;its previous (or initial) contents
  58.  
  59. ;-------any other memory fields of interest
  60. intnum2         equ     02fh            ;another interrupt number we care about
  61. intvect2        dw      intnum2*4,0     ;offset, segment (patchable)
  62.  
  63. ;-------next three entries define the window size and location
  64.         posw    corner1,1,62    ;upper left corner of window
  65.         posw    corner2,1,80    ;upper right corner
  66.         posw    corner4,5,80    ;lower right corner
  67.  
  68. ;-------next entries define location of each field within the window
  69.         posf    out1,1,1        ;moving blob goes here on line 1 of window
  70.         posf    out2,2,10       ;entry count here at line 2 col 10 of window
  71.         posf    out3,3,10       ;contents of major block being tracked
  72.         posf    out4,4,10       ;yet another block being tracked
  73.         posf    out5,5,10       ;cs:ip of routine running when timer went off
  74.  
  75. ;-------end of EQUs, etc. peculiar to a specific application of STROBE
  76.         page
  77.  
  78. ;-------next two equates are needed by the window-clearing code
  79. windwid equ     (corner2-corner1+2)/2           ;width in screen positions
  80. winddep equ     (corner4-corner2+160)/160       ;depth in lines
  81.  
  82. clknum  equ     08h             ;timer interrupt number
  83. clkvect equ     clknum*4        ;its vector address
  84.  
  85. ;-------window attributes/colors used to indicate a value change
  86. table_mono      db      20h,70h,28h,29h  ;normal, reversed, bright, underlined
  87. table_color     db      07h,04fh,2fh,5fh ;white on: black, red, green, magenta
  88. max_change      equ     3       ;n'color changes before we recycle (zero-based)
  89. change_index    dw      (max_change)     ;forces a start at first color
  90.  
  91. flags           db      0       ;flag bits...
  92. mono            equ     01h
  93. color           equ     02h
  94. sync            equ     04h
  95.  
  96. vidseg          dw      0       ;video segment address
  97. vidsegm         equ     0b000h  ;video segment address if mono
  98. vidsegc         equ     0b800h  ;video segment address if color
  99. attrib          db      0       ;screen attribute byte
  100. tick_count      dw      0       ;cyclic index into tick-display line
  101. max_tick        equ     18      ;limit for tick_count
  102. blob            equ     0feh    ;timer-tick char. feh=small square, dbh=big one
  103. entry_count     dw      0       ;count of timer-tick entries to this program
  104. count_carry     db      0       ;how many times entry_count wrapped
  105. ss_save         dw      0       ;ss saved here upon entry
  106. sp_save         dw      0       ;sp saved here
  107.  
  108. ;-------enter here on timer interrupt
  109. timer_int:
  110.         assume  cs:cseg,ds:nothing,es:nothing,ss:nothing
  111.         pushf                   ;preserve flags
  112.  
  113. ;-------switch to our own stack
  114.         cli                     ;disable interrupts (and keep them that way)
  115.         mov     ss_save,ss
  116.         mov     sp_save,sp
  117.         push    cs
  118.         pop     ss
  119.         lea     sp,stack_end
  120.         nop
  121.  
  122. ;-------save the rest of the registers
  123.         push    ax
  124.         push    bx
  125.         push    cx
  126.         push    dx
  127.         push    bp
  128.         push    di
  129.         push    si
  130.         push    ds
  131.         push    es
  132.  
  133. ;-------set ds for our internal variables, es for video buffer
  134.         push    cs
  135.         pop     ds
  136.         assume  ds:cseg
  137.         push    vidseg          ;set video segment address
  138.         pop     es              ;...
  139.  
  140. ;-------make sure our stack size hasn't been exceeded
  141. ;       (for testing; probably an unnecessary check now)
  142.         mov     ax,0fefeh               ;string that must still be there
  143.         cmp     ax,stack_bottom         ;has anyone overrun our stack?
  144.         je      check_major             ;no
  145. tight_loop:                             ;yes, so stop right here and now
  146.         mov     ax,05341h               ;but leave tracks
  147.         mov     es:corner1,ax           ;upper left corner of window
  148.         jmp     short tight_loop
  149.  
  150. check_major:
  151. ;-------check to see if value of memory field we're watching has changed:
  152.         push    ds              ;save ds for a moment
  153.         assume  ds:nothing
  154.         lds     bx,dword ptr intvect    ;load dword pointer
  155.         mov     ax,ds:[bx]      ;pick up first 2 bytes of field
  156.         mov     bx,ds:[bx+2]    ;next 2 bytes
  157.         pop     ds
  158.         assume  ds:cseg
  159.         cmp     ax,prev_value   ;still the same?
  160.         jne     has_changed     ;no
  161.         cmp     bx,prev_value+2 ;still the same?
  162.         je      clear_window    ;yes
  163. has_changed:                    ;new value.  save new field value and
  164.         call    save_major      ;alert user by changing window background color
  165.  
  166. clear_window:
  167. ;-------clear the screen window and set the background color
  168.         mov     al,20h                  ;get a blank
  169.         mov     ah,byte ptr attrib      ;pick up window color byte
  170.         mov     di,corner1      ;where to start clearing
  171.         mov     cx,winddep      ;n'lines in window
  172.         call    sync_cga        ;avoid flicker during writes if CGA display
  173. clrline:
  174.         push    cx              ;save line count
  175.         mov     cx,windwid      ;width of window
  176. clrbyte:
  177.         mov     word ptr es:0[di],ax    ;clear one screen position
  178.         inc     di
  179.         inc     di
  180.         loop    clrbyte         ;loop for all positions this line
  181.         add     di,160-(windwid*2)      ;point to next line of window
  182.         pop     cx              ;all window lines cleared?
  183.         loop    clrline         ;no
  184.  
  185. ;-------move blob from left to right on top line to indicate timer-tick rate
  186.